package jun.home.dailycost.service.impl;

import java.util.Date;
import java.util.List;

import jun.home.dailycost.dao.ItemDao;
import jun.home.dailycost.domain.Category;
import jun.home.dailycost.domain.Item;
import jun.home.dailycost.service.ItemService;

public class ItemServiceImpl implements ItemService {
	
	ItemDao itemDao;
	
	public void setItemDao(ItemDao itemDao) {
		this.itemDao = itemDao;
	}

	@Override
	public void storeItem(Item item) {
		this.itemDao.store(item);
	}

	@Override
	public void deleteItem(Item item) {
		this.itemDao.delete(item);
	}

	@Override
	public void delteItemById(int id) {
		Item item = this.itemDao.selectById(id);
		if (item != null) {
			this.itemDao.delete(item);
		}
	}

	@Override
	public Item selectItem(int id) {
		return this.itemDao.selectById(id);
	}

	@Override
	public List<Item> selectByCategory(Category cat) {
		return this.itemDao.selectByCategory(cat);
	}

	@Override
	public List<Item> select(Category cat, Date start, Date end) {
		return this.itemDao.selectByDateAndCategory(start, end, cat);
	}

	@Override
	public List<Item> select(Date start, Date end) {
		return this.itemDao.selectByDate(start, end);
	}

}
